package com.lh.controller;

import com.lh.pojo.Orders;
import com.lh.service.center.MyOrderService;
import com.lh.utils.IMOOCJSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.io.File;

/**
 * @program: foodie-dev
 * @description:
 * @author: LH
 * @create: 2022-05-21 14:42
 **/
@Controller
public class BaseController {

    public static final String FOODIE_SHOPCART = "shopcart";

    public static final Integer COMMENT_PAGE_SIZE = 10;
    public static final Integer PAGE_SIZE = 10;

    String payReturnUrl = "http://payment.t.mukewang.com/foodie-payment/payment/createMerchantOrder";

    // 微信支付成功 -> 支付中心 -> 天天吃货平台
    //                       |-> 回调通知的url
//    String returnUrl = "http://8.142.125.147:8088/foodie-dev-api/orders/notifyMerchantOrderPaid";
    String returnUrl = "http://2a4qr4.natappfree.cc/orders/notifyMerchantOrderPaid";

    public final static String IMAGE_USER_FACE_LOCATION = "D:" + File.separator +
            "Program Files" + File.separator +
            "git_Repos" + File.separator +
            "workspaces" + File.separator +
            "images" + File.separator +
            "foodie" + File.separator +
            "faces";

    @Autowired
    public MyOrderService myOrderService;

    /**
     * 用于验证用户和订单是否有关联关系，避免非法用户调用
     * @return
     */
    public IMOOCJSONResult checkUserOrder(String userId, String orderId) {
        Orders order = myOrderService.queryMyOrder(userId, orderId);
        if (order == null) {
            return IMOOCJSONResult.errorMsg("订单不存在！");
        }
        return IMOOCJSONResult.ok(order);
    }

}
